//
//  ViewController.swift
//  bollGame
//
//  Created by stu on 2019/9/17.
//  Copyright © 2019年 game. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    var redstr = "红队得分："
    var bluestr = "蓝队得分："
    
    var redNum = 0
    var blueNum = 0
    var redLepeal: [Int] = [0]
    var blueLepeal: [Int] = [0]
    @IBOutlet weak var RedScrce: UILabel!
    @IBOutlet weak var BlueScrce: UILabel!
    @IBAction func RedOne(_ sender: UIButton) {
        redNum += 1
        RedScrce.text = redstr + String(redNum)
        redLepeal.append(redNum)
        blueLepeal.append(blueNum)
    }
    @IBAction func RedTwo(_ sender: UIButton) {
        redNum += 2
        RedScrce.text = redstr + String(redNum)
        redLepeal.append(redNum)
        blueLepeal.append(blueNum)
    }
    @IBAction func RedThree(_ sender: UIButton) {
        redNum += 3
        RedScrce.text = redstr + String(redNum)
        redLepeal.append(redNum)
        blueLepeal.append(blueNum)
    }
    @IBAction func BlueOne(_ sender: UIButton) {
        blueNum += 1
        BlueScrce.text = bluestr + String(blueNum)
        redLepeal.append(redNum)
        blueLepeal.append(blueNum)
    }
    @IBAction func BlueTwo(_ sender: UIButton) {
        blueNum += 2
        BlueScrce.text = bluestr + String(blueNum)
        redLepeal.append(redNum)
        blueLepeal.append(blueNum)
    }
    @IBAction func BlueThree(_ sender: UIButton) {
        blueNum += 3
        BlueScrce.text = bluestr + String(blueNum)
        redLepeal.append(redNum)
        blueLepeal.append(blueNum)
    }
    
    
    @IBAction func NumRepeal(_ sender: UIButton) {
        if redLepeal.count != 1 {
            redLepeal.remove(at: redLepeal.count-1)
            blueLepeal.remove(at: blueLepeal.count-1)
        }
        RedScrce.text = redstr + String(redLepeal[redLepeal.endIndex-1])
        BlueScrce.text = bluestr + String(blueLepeal[blueLepeal.endIndex-1])
        redNum = redLepeal[redLepeal.endIndex-1]
        blueNum = blueLepeal[blueLepeal.endIndex-1]
    }
    
   
    
    @IBAction func ReSet(_ sender: UIButton) {
        redNum = 0
        blueNum = 0
        RedScrce.text = redstr + String(redNum)
        BlueScrce.text = bluestr + String(blueNum)
        redLepeal.append(redNum)
        blueLepeal.append(blueNum)
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

